package com.cims.action.grave;

import java.util.ArrayList;
import java.util.List;

import com.cims.action.BaseAction;
import com.cims.bo.grave.GraveBO;
import com.cims.bo.grave.GraveBOImpl;
import com.cims.common.exception.BoException;
import com.cims.common.vo.Grave;
import com.cims.common.vo.Land;

/**
 * <strong>GraveAction</strong><br>
 * <br>
 * 
 * @author AnhDN
 * @version $Id$
 */
public class GraveAction extends BaseAction{

	/** serialVersionUID */
	private static final long	serialVersionUID	= 1L;
	private GraveBO				graveBO				= new GraveBOImpl();

	private int					graveId;
	private Grave				grave				= new Grave();
	private List<Grave>			listGrave			= new ArrayList<>();
	private List<Land>			listLand			= new ArrayList<>();

	public GraveAction(){

	}

	/***
	 * List all grave type that we sell
	 */
	public String list(){
		try{
			listGrave = graveBO.getListGrave();
		}catch(Exception e){
			return ERROR;
		}
		return SUCCESS;
	}

	// find grave by grave id
	public String initUpdate(){
		System.out.println(graveId);
		try{
			grave = graveBO.findByGraveId(graveId);
		}catch(Exception e){
			// TODO: handle exception
		}

		return SUCCESS;
	}

	// update staff information
	public String update(){
		try{
			System.out.println("update");
			if(graveBO.update(grave) == true){
				return SUCCESS;
			}else{
				return ERROR;
			}
		}catch(BoException e){
			e.printStackTrace();
		}
		return SUCCESS;
	}

	// create staff
	public String insert(){
		try{
			System.out.println("insert");
			// grave.getGraveId();
			// grave.getOwner().setOwnerId(grave.getGraveId()) ;
			graveBO.insert(grave);

		}catch(Exception e){
			e.printStackTrace();
		}
		return SUCCESS;
	}

	// list grave option
	public String listGraveOption(){
		try{
			listLand = graveBO.getListLand();
		}catch(Exception e){
			// TODO: handle exception
		}
		return SUCCESS;
	}

	public GraveBO getGraveBO(){
		return graveBO;
	}

	public void setGraveBO(GraveBO graveBO){
		this.graveBO = graveBO;
	}

	public List<Grave> getListGrave(){
		return listGrave;
	}

	public void setListGrave(List<Grave> listGrave){
		this.listGrave = listGrave;
	}

	public int getGraveId(){
		return graveId;
	}

	public void setGraveId(int graveId){
		this.graveId = graveId;
	}

	public Grave getGrave(){
		return grave;
	}

	public void setGrave(Grave grave){
		this.grave = grave;
	}

	public List<Land> getListLand(){
		return listLand;
	}

	public void setListLand(List<Land> listLand){
		this.listLand = listLand;
	}
}
